<template>
  <div class="app-container">
    <el-form v-show="showSearch" ref="queryForm" :model="queryParams" size="small" :inline="true" label-width="90px">

      <el-form-item label="订单号" prop="loanNum">
        <el-input v-model="queryParams.loanNum" placeholder="请输入" clearable style="width: 200px"
          @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="客户姓名" prop="clientName">
        <el-input v-model="queryParams.clientName" placeholder="请输入" clearable style="width: 200px"
          @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="客户手机号" prop="phone">
        <el-input v-model="queryParams.phone" placeholder="请输入" clearable style="width: 200px"
          @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="催收员姓名" prop="collection">
        <el-input v-model="queryParams.collection" placeholder="请输入" clearable style="width: 200px"
          @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="还款方式" prop="paymentStatus">
        <el-select v-model="queryParams.paymentStatus" placeholder="请选择" clearable style="width: 200px">
          <!-- 字典状态，dict.type.你添加进字典的类型 -->
          <el-option v-for="dict in dict.type.order_status" :key="dict.value" :label="dict.label" :value="dict.value" />
        </el-select>
      </el-form-item>
      <el-form-item label="订单状态" prop="origin">
        <el-select v-model="queryParams.origin" placeholder="请选择" clearable style="width: 200px">
          <el-option v-for="dict in dict.type.sys_normal_disable" :key="dict.value" :label="dict.label"
            :value="dict.value" />
        </el-select>
      </el-form-item>
      <el-form-item label="渠道筛选" prop="channelName">
        <el-select v-model="queryParams.channelName" placeholder="请选择" clearable style="width: 200px">
          <el-option v-for="dict in dict.type.sys_normal_disable" :key="dict.value" :label="dict.label"
            :value="dict.value" />
        </el-select>
      </el-form-item>
      <el-form-item label="下单时间">
        <el-date-picker v-model="queryParams.applicantTimeRange" style="width: 200px" value-format="yyyy-MM-dd"
          type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" />
      </el-form-item>
      <el-form-item label="放款时间">
        <el-date-picker v-model="queryParams.creditTimeRange" style="width: 200px" value-format="yyyy-MM-dd"
          type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" />
      </el-form-item>
      <el-form-item label="分配状态" prop="channelName">
        <el-select v-model="queryParams.channelName" placeholder="请选择" clearable style="width: 200px">
          <el-option v-for="dict in dict.type.sys_normal_disable" :key="dict.value" :label="dict.label"
            :value="dict.value" />
        </el-select>
      </el-form-item>
      <el-form-item label="负责人" prop="channelName">
        <el-select v-model="queryParams.channelName" placeholder="请选择" clearable style="width: 200px">
          <el-option v-for="dict in dict.type.sys_normal_disable" :key="dict.value" :label="dict.label"
            :value="dict.value" />
        </el-select>
      </el-form-item>
      <el-form-item label="业务员" prop="salesMan">
        <el-input v-model="queryParams.salesMan" placeholder="请输入" clearable style="width: 200px"
          @keyup.enter.native="handleQuery" />
      </el-form-item>

      <el-form-item>
        <div style="margin-right: 50px;">
          <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">批量分配</el-button>
          <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">批量催收</el-button>
          <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">查询</el-button>
          <el-button size="mini" @click="resetQuery">导出</el-button>
        </div>


      </el-form-item>
    </el-form>

    <!-- data=你后台查出的数据 -->
    <el-table :data="paidOrderList">
      <el-table-column label="订单号" align="center" prop="loanNum" />
      <el-table-column label="产品名称" align="center" prop="productionName" />
      <el-table-column label="客户姓名" align="center" prop="clientName" />
      <el-table-column label="申请金额" align="center" prop="loanAmount" />
      <el-table-column label="授信额度" align="center" prop="loanAmount" />
      <el-table-column label="订单状态" align="center" prop="applicantStatusValue">
      </el-table-column>
      <el-table-column label="下单时间" align="center" prop="applicantTime" lable-width="auto">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.applicantTime) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="渠道" align="center" prop="channelName" />
      <el-table-column label="业务经理" align="center" prop="salesMan" />
      <el-table-column label="负责人" align="center" prop="principal" />
      <el-table-column label="资金方" align="center" prop="fundingAside" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button size="mini" type="text" icon="el-icon-more" @click="handleDetail(scope.row)">查看</el-button> 
        </template>
      </el-table-column>
    </el-table>
    <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getList" />
  </div>
</template>

<script>
import { listPaidOrder } from '@/api/paidOrder'
export default {
  name: 'paidOrder',
  // 字典导入
  dicts: ['loan_info_applicant_status', 'loan_info_audit_result', 'loan_info_payment_status', 'channel_channel_type'],
  data() {
    return {
      paidOrderId:undefined,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 
      paidOrderList: [],
      // 弹出层标题
      title: '',
      // 是否显示弹出层
      open: false,

      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        loanNum: undefined,
        productionName: undefined,
        clientName: undefined,

        applicantStatus: undefined,
        collection: undefined,
        channelName: undefined,
        oprationMan: undefined,
        principal: undefined,
        fundingAside: undefined,
        salesMan: undefined,
        //下单时间范围
        applicantTimeRange: [],
        //放款时间范围
        creditTimeRange: [],
      },
      // 表单参数
      form: {}
    }
  },
  created() {
    this.getList()
  },
  methods: {
    getList() {
      this.loading = true
      console.log(this.queryParams)
      listPaidOrder(this.queryParams).then(response => {
        console.log(response);
        this.paidOrderList = response.rows;
        this.total = response.total;
        this.loading = false;
      }
      );
      this.loading = false
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRange = []
      this.resetForm('queryForm')
      this.handleQuery()
    },
    handleQuery() {
      this.queryParams.pageNum = 1
      this.getList()
    },
    cancel() {
      this.open = false
      this.reset()
    },
    reset() {
      this.form = {

        status: '0'
      }
      this.resetForm('form')
    },

    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.postId)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },
    submitForm() {
      console.log('hhhhhhh')
    },
    // 查看已放款订单详情
    handleDetail(row) {
      this.paidOrderId = row.paidOrderId
      console.log(this.paidOrderId)
      this.$router.push({
        path: "/loan/paidOrder/viewDetails",
        query: {
          handle: 'viewDetails',
          id: this.paidOrderId
        }
      });
    }


  }
}
</script>

  
 
